package com.bk.bands.evaluate;

import org.apache.commons.lang.text.StrLookup;
import org.apache.commons.lang.text.StrSubstitutor;

/**
 * Created by IntelliJ IDEA.
 * User: SG0891787
 * Date: 3/11/12
 * Time: 8:12 PM
 */
public abstract class DolarEvaluator implements Evaluator
{
   private StrSubstitutor dolarSubstitutor;

   public DolarEvaluator()
   {
      this.dolarSubstitutor = new StrSubstitutor(new StrLookup()
      {
         @Override
         public String lookup(String key)
         {
            return resolve(key);
         }
      });
   }

   @Override
   public String evaluate(String valueExpression)
   {
      return dolarSubstitutor.replace(valueExpression);
   }

   public abstract String resolve(String variableName);

}
